#ifndef _HWUTIL_H_
#define _HWUTIL_H_

#include "hw_def.h"

#ifndef HEAP_END_ADDR
    #error "no HEAP_END_ADDR defined"
#endif

/*
 *
 */
#ifndef ALIGN_SIZE
    #error "no ALIGN_SIZE defined"
#endif
#define ALIGN(size)                     __ALIGN(size, ALIGN_SIZE)
/******************************************************************************/

/*
 *
 */
#define ITOC_RS0(x)                     (char)(x >> 0)
#define ITOC_RS8(x)                     (char)(x >> 8)
#define ITOC_RS16(x)                    (char)(x >> 16)
#define ITOC_RS24(x)                    (char)(x >> 24)
/******************************************************************************/
/******************************************************************************/
/******************************************************************************/
/******************************************************************************/

#define PHYS_ADDR_ALIGN(addr)           (ALIGN((phys_addr_t)addr) == (phys_addr_t)addr)

#if USING_KERNEL_MEMORY_ISOLATION
    #define __user
    #define __kernel
#else
    #define __user
    #define __kernel    
#endif

#if USING_KERNEL_SECTION
    #define KERNEL_SECTION SECTION("kernel_rw")
#else
    #define KERNEL_SECTION 
#endif

#ifndef interrupt_suspend
    #error "no interrupt_suspend function"
#endif 

#ifndef interrupt_recover
    #error "no interrupt_recover function"
#endif
   
#ifndef context_switch
    #error "no context_switch function"
#endif
   
#ifndef context_switch_to
    #error "no context_switch_to function"
#endif
    
#ifndef TASKSCHED_PERIOD
    #define TASKSCHED_PERIOD 1000
#endif

#endif
